<admintpl file="header" />
</head>
<body>
	<div class="wrap js-check-wrap">
		<ul class="nav nav-tabs">
			<li class="active"><a href="{:U('Paper/index',array('paper_type'=>$paper_type))}">试卷管理</a></li>
			<li><a href="{:U('Paper/add',array('paper_type'=>$paper_type))}" target="_self">添加试卷</a></li>
			
		</ul>
		<form class="well form-search" method="post" action="{:U('Paper/index',array('paper_type'=>$paper_type))}">
			分类： 
			<select name="term_id" style="width: 120px;">
				<option value='0'>全部</option>{$taxonomys}
			</select> &nbsp;&nbsp;
			试卷ID： 
			<input type="text" name="id" style="width: 200px;" value="{$id}" placeholder="请输入试卷ID">
			题干：
			<input type="text" name="keyword" style="width: 200px;" value="{$keyword}" placeholder="请输入题干">
			<input type="submit" class="btn btn-primary" value="搜索" />
			<a class="btn btn-danger" href="{:U('Paper/index')}">清空</a>
		</form>
		<form class="js-ajax-form" action="" method="post">
			<div class="table-actions" style="display:none">
				<notempty name="term">
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/listorders')}">{:L('SORT')}</button>
				</notempty>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/check',array('check'=>1))}" data-subcheck="true">审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/check',array('uncheck'=>1))}" data-subcheck="true">取消审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/top',array('top'=>1))}" data-subcheck="true">置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/top',array('untop'=>1))}" data-subcheck="true">取消置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/recommend',array('recommend'=>1))}" data-subcheck="true">推荐</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/recommend',array('unrecommend'=>1))}" data-subcheck="true">取消推荐</button>
				<notempty name="term">
					<button class="btn btn-primary btn-small js-articles-move" type="button">批量移动</button>
				</notempty>
				<button class="btn btn-primary btn-small js-articles-copy" type="button">批量复制</button>
				<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/delete')}" data-subcheck="true" data-msg="您确定删除吗？">{:L('DELETE')}</button>
			</div>
			<table class="table table-hover table-bordered table-list">
				<thead>
					<tr>
						<th width="30">ID</th>
						<th width="140">试卷名称</th>
						<th width="75">试卷分类</th>
						<th width="50">评券方式</th>
						<th width="50">选题方式</th>
						<th width="50">试卷分数</th>
						<th width="40">作者</th>
						<th width="90">发布时间</th>
						<th width="90">更新时间</th>
						<th width="30">状态</th>
						<th width="140">操作</th>
					</tr>
				</thead>
				<foreach name="posts" item="vo">
				<tr>					
                    <td><b>{$vo.id}</b></td>
					<td><a alt="点击看题" href="javascript:review('{:U('paper/review','id='.$vo['id'])}');">{$vo.paper_name}</a> </td>
					<td>{$paper_terms[$vo['paper_term']]}</td>
					<td>{$vo.paper_judge_type}</td>
					<td>{$vo.paper_choose_type}</td>
					<td>{$vo.paper_score}分</td>
					<td>{$vo.user_nicename|default=$vo.user_login}</td>					
					<td>{:date('Y-m-d H:i',strtotime($vo['paper_date']))}</td>
					<td>
					<empty name="vo['paper_modified']">-
					<else />
					{:date('Y-m-d H:i',strtotime($vo['paper_modified']))}
					</empty>
					<td>
						<eq name="vo['paper_status']" value='0'>
							<a data-toggle="tooltip" title="已启用"><i class="fa fa-check"></i></a>
							<else/>
							<a data-toggle="tooltip" title="已停用"><i class="fa fa-close"></i></a>
						</eq>
					</td>
					<td>
						<eq name="vo['paper_choose_type']" value="随机选题"><a href="javascript:generate_paper({$vo.id})">重新生成</a> | </eq>
						<a href="javascript:review('{:U('paper/review','id='.$vo['id'])}');">看题</a> | 
						<a href="{:U('Paper/edit',array('id'=>$vo['id']))}">{:L('EDIT')}</a> | 
						<a href="{:U('Paper/delete',array('id'=>$vo['id']))}" class="js-ajax-delete">{:L('DELETE')}</a>
					</td>
				</tr>
				</foreach>
				<tfoot>
					<tr>						
						<th>ID</th>
						<th>试卷名称</th>
						<th>试卷分类</th>
						<th>评券方式</th>
						<th>选题方式</th>
						<th>试卷分数</th>
						<th>作者</th>
						<th>发布时间</th>
						<th>更新时间</th>
						<th>状态</th>
						<th>操作</th>
					</tr>
				</tfoot>
			</table>
			<div class="table-actions" style="display:none">
				<notempty name="term">
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/listorders')}">{:L('SORT')}</button>
				</notempty>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/check',array('check'=>1))}" data-subcheck="true">审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/check',array('uncheck'=>1))}" data-subcheck="true">取消审核</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/top',array('top'=>1))}" data-subcheck="true">置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/top',array('untop'=>1))}" data-subcheck="true">取消置顶</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/recommend',array('recommend'=>1))}" data-subcheck="true">推荐</button>
				<button class="btn btn-primary btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/recommend',array('unrecommend'=>1))}" data-subcheck="true">取消推荐</button>
				<notempty name="term">
					<button class="btn btn-primary btn-small js-articles-move" type="button">批量移动</button>
				</notempty>
				<button class="btn btn-primary btn-small js-articles-copy" type="button">批量复制</button>
				<button class="btn btn-danger btn-small js-ajax-submit" type="submit" data-action="{:U('Paper/delete')}" data-subcheck="true" data-msg="你确定删除吗？">{:L('DELETE')}</button>
			</div>
			<div class="pagination">{$page}</div>
		</form>
	</div>
	<script src="__PUBLIC__/js/common.js"></script>
	<script type="text/javascript" src="__PUBLIC__/js/layer/layer.js"></script>
	<script>
		function review(url){			
			layer.open({
			      type: 2,
			      title: '试卷预览',
			      shadeClose: true,
			      shade: false,
			      maxmin: true, //开启最大化最小化按钮
			      area: ['893px', '870px'],
			      content: url,
			      success:function(layero, index){
			    	  layer.full(index);
			      }
			});
		}
		function generate_paper(id){
			Wind.use('artDialog', function() {

				$.post("{:U('paper/generate_paper')}"+"&id="+id, function(data) {
					art.dialog({
						id : "succeed",
						icon : "succeed",
						fixed : true,
						lock : true,
						background : "#CCCCCC",
						opacity : 0,
						content : data.info,
						button : [ {
							name : '知道了',
							callback : function() {
								return true;
							}
						} ]
					});
				});
			});
		}
// 		function refersh_window() {
// 			var refersh_time = getCookie('refersh_time');
// 			if (refersh_time == 1) {
// 				window.location = "{:U('Paper/index',$formget)}";
// 			}
// 		}
		
// 		setInterval(function() {
// 			refersh_window();
// 		}, 2000);
		$(function() {

			
			setCookie("refersh_time", 0);
			Wind.use('ajaxForm', 'artDialog', 'iframeTools', function() {
				//批量复制
				$('.js-articles-copy').click(function(e) {
					var ids=[];
					$("input[name='ids[]']").each(function() {
						if ($(this).is(':checked')) {
							ids.push($(this).val());
						}
					});
					
					if (ids.length == 0) {
						art.dialog.through({
							id : 'error',
							icon : 'error',
							content : '您没有勾选信息，无法进行操作！',
							cancelVal : '关闭',
							cancel : true
						});
						return false;
					}
					
					ids= ids.join(',');
					art.dialog.open("__ROOT__/index.php?g=portal&m=Paper&a=copy&ids="+ ids, {
						title : "批量复制",
						width : "300px"
					});
				});
				//批量移动
				$('.js-articles-move').click(function(e) {
					var ids=[];
					$("input[name='ids[]']").each(function() {
						if ($(this).is(':checked')) {
							ids.push($(this).val());
						}
					});
					
					if (ids.length == 0) {
						art.dialog.through({
							id : 'error',
							icon : 'error',
							content : '您没有勾选信息，无法进行操作！',
							cancelVal : '关闭',
							cancel : true
						});
						return false;
					}
					
					ids= ids.join(',');
					art.dialog.open("__ROOT__/index.php?g=portal&m=Paper&a=move&old_term_id={$term.term_id|default=0}&ids="+ ids, {
						title : "批量移动",
						width : "300px"
					});
				});
			});
		});
	</script>
</body>
</html>